/*
v0.001

combat landing script for RUM Assets

RUM_CBLand.sqf
© January 2013 - VRCRaptor (raptor@vrcombat.com)
*/

	_helo = _this select 0;
	sleep 3;
	// _crewCount = _helo getVariable ["_crewVariable",(count crew _helo)];
	// _helo setVariable ["_crewVariable",_crewCount,true];
	
	player globalchat format ["start crew %1",_crewCount];
	
	if(!alive _helo)exitwith{};

	private ["_combDrop"];
	_combDrop = false;
	_helo land "get out";

	while {!_combDrop} do {
		_helo_height =  getpos _helo select 2;
		
		if ((round _helo_height) <= 12) then {
			_helo flyinheight 2.75;
			_helo domove getpos _helo;
			_combDrop = true;
		};
		hintsilent format ["%1's current altitude is: %2",_helo, _helo_height];
		sleep 0.5;
	};

	[_helo] spawn {
		_safe = false;
		_helo = _this select 0;
		_crewCount = (_helo getVariable "_crewVariable");
		while {!_safe} do {
			sleep 1;
			hintsilent format ["%1 crew in %2",count crew _helo, _helo];
			if ((count(crew _helo) <= _crewCount)) then {
				hintsilent format ["There are %1 crew in %2, moving out.",count (crew _helo), _helo];
				_helo setVariable ["RUM_THel_continue",true,true];
				_safe = true;
			};
		};
	};

	_helo globalchat "Holding till troops have disembarked";
	_helo setVariable ["RUM_THel_continue",false,true];
	waitUntil {(!alive _helo) or (_helo getVariable "RUM_THel_continue")};

	_helo globalchat "Moving On!";
	
	_helo setVariable ["_crewVariable",nil]; 
	_helo setVariable ["RUM_THel_continue",nil];


	if(true)exitwith{};
